import Taro, { Component } from '@tarojs/taro';
import { View } from '@tarojs/components';
import moment from 'moment';

import './style.less';

import SubTitle from '../SubTitle';
import Lately from '../Lately';

class Title extends Component {
  constructor(props) {
    super(props)
    this.state = {
      time: moment(),
    }
  }
  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  changeTime = (time) => {
    this.setState({ time });
  }

  render() {
    const { time } = this.state;
    return (
      <View className='title'>
        <View className='label'>
          <SubTitle type='special' title={`${time.format('YYYY-MM') }月`} rightTitle='历史表现' />
        </View>
        <Lately time={time.format('YYYY-MM-DD')} onSetTime={this.changeTime} />
      </View>
    )
  }
}

export default Title;
